import Vue from 'vue'
import VueRouter from 'vue-router'

// 解决导航栏中的vue-router在3.0版本以上重复点菜单报错问题
// const originalPush = VueRouter.prototype.push
// VueRouter.prototype.push = function push(location) {
//   return originalPush.call(this, location).catch(err => err)
// }
const Home = () => import ('../views/home/Home.vue');
const Cart = () => import ('../views/cart/Cart.vue');
const Category = () => import ('../views/category/Category.vue');
const Profile = () => import ('../views/profile/Profile.vue');
const Detail = () => import ('../views/detail/Detail.vue');

Vue.use(VueRouter);

const routes = [
    { path: '', redirect: '/home' },
    //购物街
    { path: '/home', component: Home },
    //购物车
    { path: '/cart', component: Cart },
    //分类
    { path: '/category', component: Category },
    //个人
    { path: '/profile', component: Profile },
    // 动态路由
    { path: '/detail/:iid', component: Detail}
]

const router = new VueRouter({
    mode: 'history',
    base: process.env.BASE_URL,
    routes
})
export default router